package com.fh.lib_base.util

import java.text.SimpleDateFormat
import java.util.*

object DateUtil {
    /**
     * 根据日期获取周几
     * yyyy-MM-dd
     */
    fun getWeekByDate(date: String): String{

        var format = SimpleDateFormat("yyyy-MM-dd")
        var start = format.parse(date)

        var calendar = Calendar.getInstance()
        calendar.time = start
        var startWeek = calendar.get(Calendar.DAY_OF_WEEK)

        when(startWeek){
            1->{ return "周日"}
            2->{ return "周一"}
            3->{ return "周二"}
            4->{ return "周三"}
            5->{ return "周四"}
            6->{ return "周五"}
            7->{ return "周六"}
            else->{
                return "unknow"
            }
        }
    }
}